﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>云科技</title>
        <link type="text/css" rel="stylesheet" media="all" href="../styles/global.css" />
        <link type="text/css" rel="stylesheet" media="all" href="../styles/global_color.css" /> 
        <script language="javascript" type="text/javascript">
            //删除
            function deleteAccount() {
                var r = window.confirm("确定要删除此账务账号吗？\r\n删除后将不能恢复，且会删除其下属的所有业务账号。");
                document.getElementById("operate_result_info").style.display = "block";
            }
            //开通或暂停
            function setState() {
                var r = window.confirm("确定要开通此账务账号吗？");
                document.getElementById("operate_result_info").style.display = "block";
            }
        </script>
    </head>
    <body>
        <!--Logo区域开始-->
        <div id="header">
            <img src="../images/logo.png" alt="logo" class="left"/>
            <a href="/logout">[退出]</a>
        </div>
        <!--Logo区域结束-->
        <!--导航区域开始-->
        <div id="navi">                        
            <ul id="menu">
                <li><a href="/index" class="index_on"></a></li>
                <li id="lia1"><a href="/role_list" class="role_off"></a></li>
                <li id="lia2"><a href="/admin_list" class="admin_off"></a></li>
                <li id="lia3"><a href="/fee_list" class="fee_off"></a></li>
                <li id="lia4"><a href="/account_list" class="account_off"></a></li>
                <li id="lia5"><a href="/service_list" class="service_off"></a></li>
                <li id="lia6"><a href="/bill_list" class="bill_off"></a></li>
                <li id="lia7"><a href="/report_list" class="report_off"></a></li>
                <li><a href="/userInfo" class="information_off"></a></li>
                <li><a href="/userModifyPwd" class="password_off"></a></li>
            </ul>            
        </div>
        <!--导航区域结束-->
        <!--主要区域开始-->
        <div id="main">
            <form action="" method="">
                <!--查询-->
                <div class="search_add">                        
                    <div>身份证：<input type="text"  class="text_search" id="sfz"/></div>
                    <div>姓名：<input type="text" class="width70 text_search" id="zm"/></div>
                    <div>登录名：<input type="text"  id="dlm" class="text_search"/></div>
                    <div>
                        状态：
                        <select id="select_search">
                            <option>开通</option>
                            <option>暂停</option>
                        </select>
                    </div>
                    <div><input type="button" value="搜索" id="btn_search" /></div>
                    <input type="button" value="增加" class="btn_add" onclick="location.href='account_add.html';" />
                </div>  
                <!--删除等的操作提示-->
                <div id="operate_result_info" class="operate_success">
                    <img src="../images/close.png" onclick="this.parentNode.style.display='none';" />
                    删除成功，且已删除其下属的业务账号！
                </div>   
                <!--数据区域：用表格展示数据-->     
                <div id="data">            
                    <table id="datalist">
                    <tr>
                        <th>账号ID</th>
                        <th>姓名</th>
                        <th class="width150">身份证</th>
                        <th>登录名</th>
                        <th>状态</th>
                        <th class="width140">创建日期</th>
                        <th class="width150">上次登录时间</th>                                                        
                        <th class="width200"></th>
                    </tr>
                </table>
                <p>业务说明：<br />
                1、创建则开通，记载创建时间；<br />
                2、暂停后，记载暂停时间；<br />
                3、重新开通后，删除暂停时间；<br />
                4、删除后，记载删除时间，标示为删除，不能再开通、修改、删除；<br />
                5、暂停账务账号，同时暂停下属的所有业务账号；<br />                
                6、暂停后重新开通账务账号，并不同时开启下属的所有业务账号，需要在业务账号管理中单独开启；<br />
                7、删除账务账号，同时删除下属的所有业务账号。</p>
                </div>                   
                <!--分页-->
                <div id="pages">

                </div>                    
            </form>
        </div>
        <!--主要区域结束-->
        <div id="footer">
            <p>[源自北美的技术，最优秀的师资，最真实的企业环境，最适用的实战项目]</p>
            <p>版权所有(C)云科技有限公司 </p>
        </div>
    </body>
    <script src="/js/jquery-3.2.1.js"></script>
    <script>
        show();
        accountpage();
        function show() {

            $.ajax({
                url: "/selectAllModules",
                type: "post",
                success: function (result) {

                    if (result.indexOf("角色管理") == -1) {
                        document.getElementById("lia1").style.display = "none"
                    }
                    if (result.indexOf("管理员") == -1) {
                        document.getElementById("lia2").style.display = "none"
                    }
                    if (result.indexOf("资费管理") == -1) {
                        document.getElementById("lia3").style.display = "none"
                    }
                    if (result.indexOf("账务账号") == -1) {
                        document.getElementById("lia4").style.display = "none"
                    }
                    if (result.indexOf("业务账号") ==-1) {
                        document.getElementById("lia5").style.display = "none"
                    }
                    if (result.indexOf("账单管理") ==-1) {
                        document.getElementById("lia6").style.display = "none"
                    }
                    if (result.indexOf("报表") == -1) {
                        document.getElementById("lia7").style.display = "none"
                    }


                }

            });
        }

        function accountpage() {
            $.ajax({
                url: "/accountpage",
                method: "post",
                data: {
                    pageNum: 1,
                    pageSize: 3
                },
                success: function (result) {

                    resultData(result);
                }
            });
        }
        function page(pagenum) {
            $.ajax({
                url: "/accountpage",
                type: "post",
                data: {
                    pageNum: pagenum,
                    pageSize: 3
                },
                success: function (result) {
                    resultData(result);
                }
            });
        }
        function tiao(id) {
            window.location.href = "/account_modi?id=" + id;
        }

        function setState(accountId, status) {
            $.ajax({
                url: "/AccountstarOrStop",
                type: "post",
                data: {
                    id: accountId,
                    status: status
                },
                success: function (result) {
                    window.location.href = result.msg
                }

            });

        }
        function setDelState(accountId) {
            $.ajax({
                url: "/AccountstarOrStop",
                type: "post",
                data: {
                    id: accountId,
                    status: 2
                },
                success: function (result) {
                    window.location.href = result.msg
                }

            });

        }

        function resultData(result) {
            $("#datalist").html("");
            $("#datalist").append("<tr>" +
                    "<th>账号ID</th>" +
                    "<th >姓名</th>" +
                    "<th class='width150'>身份证</th>" +
                    "<th >登录名</th>" +
                    "<th >状态</th>" +
                    "<th class='width140'>创建日期</th>" +
                    "<th class='width150'>上次登录时间</th>" +
                    "<th class='width200'></th>" +
                    "</tr>");
            var pagenum = result.pageNum;
            //每页显示几条数据
            var pagesize = result.pageSize;
            var size = result.size;
            var startrow = result.startRow;
            var endrow = result.startRow;
            var total = result.total;
            var pages = result.pages;
            var firstpage = result.firstPage;
            var prepage = result.prePage;
            var nextpage = result.nextPage;
            var lastpage = result.lastPage;
            var isfirstpage = result.isFirstPage;
            var islastpage = result.isLastPage;
            var haspreviouspage = result.hasPreviiousPage;
            var hasnextpage = result.hasNextPage;
            var navigatepages = result.navigatePages;
            var navigatepagenums = result.navigatepageNums;
            var adminList = result.list;

            if (isfirstpage) {
                prepage = firstpage
            }
            if (islastpage) {
                nextpage = lastpage;
            }
            for (var i = 0; i < adminList.length; i++) {
                var accountBean = adminList[i];
                var tr = $("<tr></tr>");
                var accountIdTd = $("<td></td>");
                var serId = $("<a href='/account_detail?account="+accountBean.accountId+"'></a>").text(accountBean.accountId);
                accountIdTd.append(serId);
                var accountNameTd = $("<td></td>").text(accountBean.realName);
                var sfzTd = $("<td></td>").text(accountBean.idcardNo);
                var dlmTd = $("<td></td>").text(accountBean.loginName);
                var ztTd = $("<td></td>").text(accountBean.status == '1' ? '启用' : '暂停');
                if (accountBean.status==2){
                    ztTd = $("<td></td>").text("删除");
                }
                var cjRqTd =$("<td></td>").text(accountBean.createDate);
                var scdlsjTd =$("<td></td>").text(accountBean.lastLoginTime);
                if (accountBean.status == 2) {
                    var changeBtn = $("<td class='inputtd'></td>").css("display", "none");
                }else {
                    changeBtn= $("<td id='inputtd'></td>").css("display","block");
                }
                var in1 = $("<input type='button' value='暂停' class='btn_pause' id='btn' onclick='setState(" + accountBean.accountId + "," + accountBean.status + ")'/>").val(accountBean.status == 1 ? '暂停' : '启用');
                var in2 = $("<input type='button' value='修改' class='btn_modify'  onclick='tiao(" + accountBean.accountId + ")'/>");
                var in3 = $("<input type='button' value='删除' class='btn_delete'  onclick='setDelState(" + accountBean.accountId + ")'/>");

                changeBtn.append(in1).append(in2).append(in3);
                tr.append(accountIdTd).append(accountNameTd).append(sfzTd).append(dlmTd)
                        .append(ztTd).append(cjRqTd).append(scdlsjTd).append(status).append(changeBtn);
                $("#datalist").append(tr);
            }
            $("#pages").html("");
            var a11 = $("<a href='javascript:void(0)' onclick='page(" + firstpage + ")'></a>").text("首页");
            var a12 = $("<a href='javascript:void(0)' onclick='page(" + prepage + ")'></a>").text("上一页");
            $("#pages").append(a11).append(a12);
            for (var k = 1; k <= lastpage; k++) {
                $("#pages").append($("<a href='javascript:void(0)' onclick='page(" + k + ")' >" + k + "</a>"));
            }
            var a13 = $("<a href='javascript:void(0)' onclick='page(" + nextpage + ")'></a>").text("下一页");
            var a14 = $("<a href='javascript:void(0)' onclick='page(" + lastpage + ")'></a>").text("尾页");
            $("#pages").append(a13).append(a14);
        }

        function searchData(result) {
            $("#datalist").html("");
            $("#datalist").append("<tr>" +
                    "<th>账号ID</th>" +
                    "<th >姓名</th>" +
                    "<th class='width150'>身份证</th>" +
                    "<th >登录名</th>" +
                    "<th >状态</th>" +
                    "<th class='width140'>创建日期</th>" +
                    "<th class='width150'>上次登录时间</th>" +
                    "<th class='width200'></th>" +
                    "</tr>");
            var pagenum = result.pageNum;
            //每页显示几条数据
            var pagesize = result.pageSize;
            var size = result.size;
            var startrow = result.startRow;
            var endrow = result.startRow;
            var total = result.total;
            var pages = result.pages;
            var firstpage = result.firstPage;
            var prepage = result.prePage;
            var nextpage = result.nextPage;
            var lastpage = result.lastPage;
            var isfirstpage = result.isFirstPage;
            var islastpage = result.isLastPage;
            var haspreviouspage = result.hasPreviiousPage;
            var hasnextpage = result.hasNextPage;
            var navigatepages = result.navigatePages;
            var navigatepagenums = result.navigatepageNums;
            var adminList = result.list;

            if (isfirstpage) {
                prepage = firstpage
            }
            if (islastpage) {
                nextpage = lastpage;
            }
            for (var i = 0; i < adminList.length; i++) {
                var accountBean = adminList[i];
                var tr = $("<tr></tr>");
                var accountIdTd = $("<td></td>");
                var serId = $("<a href='/account_detail?account="+accountBean.accountId+"'></a>").text(accountBean.accountId);
                accountIdTd.append(serId);
                var accountNameTd = $("<td></td>").text(accountBean.realName);
                var sfzTd = $("<td></td>").text(accountBean.idcardNo);
                var dlmTd = $("<td></td>").text(accountBean.loginName);
                var ztTd = $("<td></td>").text(accountBean.status == '1' ? '启用' : '暂停');
                if (accountBean.status==2){
                    ztTd = $("<td></td>").text("删除");
                }
                var cjRqTd =$("<td></td>").text(accountBean.createDate);
                var scdlsjTd =$("<td></td>").text(accountBean.lastLoginTime);
                if (accountBean.status == 2) {
                    var changeBtn = $("<td class='inputtd'></td>").css("display", "none");
                }else {
                    changeBtn= $("<td id='inputtd'></td>").css("display","block");
                }
                var in1 = $("<input type='button' value='暂停' class='btn_pause' id='btn' onclick='setState(" + accountBean.accountId + "," + accountBean.status + ")'/>").val(accountBean.status == 1 ? '暂停' : '启用');
                var in2 = $("<input type='button' value='修改' class='btn_modify'  onclick='tiao(" + accountBean.accountId + ")'/>");
                var in3 = $("<input type='button' value='删除' class='btn_delete'  onclick='setDelState(" + accountBean.accountId + ")'/>");

                changeBtn.append(in1).append(in2).append(in3);
                tr.append(accountIdTd).append(accountNameTd).append(sfzTd).append(dlmTd)
                        .append(ztTd).append(cjRqTd).append(scdlsjTd).append(status).append(changeBtn);
                $("#datalist").append(tr);
            }
            $("#pages").html("");
            var a11 = $("<a href='javascript:void(0)' onclick='searchpage(" + firstpage + ")'></a>").text("首页");
            var a12 = $("<a href='javascript:void(0)' onclick='searchpage(" + prepage + ")'></a>").text("上一页");
            $("#pages").append(a11).append(a12);
            for (var k = 1; k <= lastpage; k++) {
                $("#pages").append($("<a href='javascript:void(0)' onclick='searchpage(" + k + ")' >" + k + "</a>"));
            }
            var a13 = $("<a href='javascript:void(0)' onclick='searchpage(" + nextpage + ")'></a>").text("下一页");
            var a14 = $("<a href='javascript:void(0)' onclick='searchpage(" + lastpage + ")'></a>").text("尾页");
            $("#pages").append(a13).append(a14);
        }

        function accountSearchpage() {
            $.ajax({
                url: "/accountsearch",
                method: "post",
                data: {
                    pageNum: 1,
                    pageSize: 3,
                    loginName: $("#dlm").val(),
                    idCardNo:  $("#sfz").val(),
                    realName:  $("#zm").val(),
                    status: $("#select_search").val() == '开通' ? 1 : 0
                },
                success: function (result) {
                    searchData(result);
                }
            });
        }

        function searchpage(pagenum) {
            $.ajax({
                url: "/accountsearch",
                type: "post",
                data: {
                    pageNum: pagenum,
                    pageSize: 3,
                    loginName: $("#dlm").val(),
                    idCardNo:  $("#sfz").val(),
                    realName:  $("#zm").val(),
                    status: $("#select_search").val() == '开通' ? 1 : 0
                },
                success: function (result) {
                    searchData(result);
                }
            });
        }

        $("#btn_search").click(function () {
            accountSearchpage();
        });
    </script>
</html>
